
/** signals.d: The unit test for signals.d

  Written in the D programming language 1.0

Authors:	Wei Li (oldrev@gmail.com)
Copyright:	Copyright (C) 2007 by Wei Li.
License:	BSD
*/

module test.base.testsignals;

import dotmars.base.signals;
import dotmars.test.core;

class SignalTestCase : TestCase!(SignalTestCase)
{

	this()
	{
		register("testSignal", &testSignal);
	}

	void testSignal() 
	{
		class Window
		{
			bool pressed;

			this() { 
				pressed = false; 
			}

			Signal!() clickSignal;
		}

		auto w = new Window;

		void onClick1() { w.pressed = true; }
		void onClick2() { /*do nothing*/ }

		w.clickSignal += &onClick1;
		w.clickSignal += &onClick2;

		assertTrue((&onClick1) in w.clickSignal);

		assertTrue(w.clickSignal.connected(&onClick1));
		assertTrue(w.clickSignal.connected(&onClick2));

		w.clickSignal(); //Fire the event

		assertTrue(w.pressed);
	}
}

